package game.module.award.logic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.common.AwardConstants;
import game.entity.PlayingRole;
import lua.LuaMessageHall.PushPropChange;

public class AwardUtil {

	private static Logger logger = LoggerFactory.getLogger(AwardUtil.class);

	public static void send(PlayingRole playingRole, int awardType, int awardVal, int moduleType) {
		logger.info("send award,playerId={},awardType={},awardVal={}", playingRole.getPlayerBean().getId(), awardType,
				awardVal);
		switch (awardType) {
		case AwardConstants.FANG_KA:
			int fangkaNum = playingRole.getPlayerBean().getFang_ka();
			fangkaNum += awardVal;
			fangkaNum = fangkaNum < 0 ? 0 : fangkaNum;
			playingRole.getPlayerBean().setFang_ka(fangkaNum);
			PushPropChange propChangeMsg = new PushPropChange(awardType, fangkaNum);
			playingRole.getGamePlayer().write(propChangeMsg.build(playingRole.alloc()));
			break;
		case AwardConstants.JIN_DOU:
			long jindou = playingRole.getPlayerBean().getJin_dou();
			jindou += awardVal;
			jindou = jindou < 0 ? 0 : jindou;
			playingRole.getPlayerBean().setJin_dou(jindou);
			PushPropChange propChangeMs = new PushPropChange(awardType,(int)jindou);
			playingRole.getGamePlayer().write(propChangeMs.build(playingRole.alloc()));
		default:
			break;
		}
	}

}
